﻿using System;

namespace Poly2Tri
{
	// Token: 0x02000402 RID: 1026
	public class TriangulationConstraint : Edge
	{
		// Token: 0x06001C9B RID: 7323 RVA: 0x000B3014 File Offset: 0x000B1214
		public TriangulationConstraint(TriangulationPoint p1, TriangulationPoint p2)
		{
			this.mP = p1;
			this.mQ = p2;
			if (p1.Y > p2.Y)
			{
				this.mQ = p1;
				this.mP = p2;
			}
			else if (p1.Y == p2.Y)
			{
				if (p1.X > p2.X)
				{
					this.mQ = p1;
					this.mP = p2;
				}
				else if (p1.X == p2.X)
				{
				}
			}
			this.CalculateContraintCode();
		}

		// Token: 0x17000414 RID: 1044
		// (get) Token: 0x06001C9C RID: 7324 RVA: 0x000B30A5 File Offset: 0x000B12A5
		// (set) Token: 0x06001C9D RID: 7325 RVA: 0x000B30B2 File Offset: 0x000B12B2
		public TriangulationPoint P
		{
			get
			{
				return this.mP as TriangulationPoint;
			}
			set
			{
				if (value != null && this.mP != value)
				{
					this.mP = value;
					this.CalculateContraintCode();
				}
			}
		}

		// Token: 0x17000415 RID: 1045
		// (get) Token: 0x06001C9E RID: 7326 RVA: 0x000B30D3 File Offset: 0x000B12D3
		// (set) Token: 0x06001C9F RID: 7327 RVA: 0x000B30E0 File Offset: 0x000B12E0
		public TriangulationPoint Q
		{
			get
			{
				return this.mQ as TriangulationPoint;
			}
			set
			{
				if (value != null && this.mQ != value)
				{
					this.mQ = value;
					this.CalculateContraintCode();
				}
			}
		}

		// Token: 0x17000416 RID: 1046
		// (get) Token: 0x06001CA0 RID: 7328 RVA: 0x000B3101 File Offset: 0x000B1301
		public uint ConstraintCode
		{
			get
			{
				return this.mContraintCode;
			}
		}

		// Token: 0x06001CA1 RID: 7329 RVA: 0x000B310C File Offset: 0x000B130C
		public override string ToString()
		{
			return string.Concat(new string[]
			{
				"[P=",
				this.P.ToString(),
				", Q=",
				this.Q.ToString(),
				" : {",
				this.mContraintCode.ToString(),
				"}]"
			});
		}

		// Token: 0x06001CA2 RID: 7330 RVA: 0x000B3174 File Offset: 0x000B1374
		public void CalculateContraintCode()
		{
			this.mContraintCode = TriangulationConstraint.CalculateContraintCode(this.P, this.Q);
		}

		// Token: 0x06001CA3 RID: 7331 RVA: 0x000B3190 File Offset: 0x000B1390
		public static uint CalculateContraintCode(TriangulationPoint p, TriangulationPoint q)
		{
			if (p == null || p == null)
			{
				throw new ArgumentNullException();
			}
			uint nInitialValue = MathUtil.Jenkins32Hash(BitConverter.GetBytes(p.VertexCode), 0U);
			return MathUtil.Jenkins32Hash(BitConverter.GetBytes(q.VertexCode), nInitialValue);
		}

		// Token: 0x04001D9B RID: 7579
		private uint mContraintCode;
	}
}
